import { EnumSchema } from '@/utils/common/types';
import { PresetColorEnum } from '@/enums/colorEnum';

//#region 产品类型
export enum ProductTypeEnum {
  Desktop = 0,
  Portable,
  Hand,
  Remote,
}

export class ProductTypeEntity {
  Type: ProductTypeEnum;
  /** 显示描述 */
  Display: string;
  /** 颜色 */
  Color?: PresetColorEnum | string;

  constructor(productType: ProductTypeEnum, color?: PresetColorEnum | string) {
    this.Type = productType;
    this.Color = color;
    switch (productType) {
      case ProductTypeEnum.Desktop:
        this.Display = '台式';
        this.Color = this.Color ? this.Color : PresetColorEnum.Green;
        break;
      case ProductTypeEnum.Portable:
        this.Display = '便携';
        this.Color = this.Color ? this.Color : PresetColorEnum.Blue;
        break;
      case ProductTypeEnum.Hand:
        this.Display = '掌上';
        this.Color = this.Color ? this.Color : PresetColorEnum.Cyan;
        break;
      case ProductTypeEnum.Remote:
        this.Display = '远程';
        this.Color = this.Color ? this.Color : PresetColorEnum.Orange;
        break;
    }
  }
}

export function getProductTypeEnumSchema(enableTag = true): EnumSchema[] {
  const enumSchema: EnumSchema[] = [];
  const typeEntities: ProductTypeEntity[] = [
    new ProductTypeEntity(ProductTypeEnum.Desktop),
    new ProductTypeEntity(ProductTypeEnum.Portable),
    new ProductTypeEntity(ProductTypeEnum.Hand),
    new ProductTypeEntity(ProductTypeEnum.Remote),
  ];
  typeEntities.forEach((item) => {
    enumSchema.push({
      key: item.Type as number,
      label: item.Display,
      value: item.Type as number,
      tag: enableTag,
      tagColor: item.Color,
    });
  });
  return enumSchema;
}
//#endregion
